package DoExercise.JianzhiOffer;

import java.util.LinkedList;

/**
 * @Author: Du
 * @Date: 2022-1-25 16:02
 * <p>
 * https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/
 */
public class Offer083_用两个栈实现队列
{
    
    public LinkedList<Integer> listIn, listOut;
    
    
    public Offer083_用两个栈实现队列()
    {
        listIn = new LinkedList();
        listOut = new LinkedList();
    }
    
    public void appendTail(int value)
    {
        if (value > 10000 || value < 1) return;
        listIn.addLast(value);
    }
    
    public int deleteHead()
    {
        if (!listOut.isEmpty()) return listOut.removeLast();
        if (listIn.isEmpty()) return -1;
        while (!listIn.isEmpty()) listOut.addLast(listIn.removeLast());
        return listOut.removeLast();
    }
}
